﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Common
{
    public class MSSetup
    {
        public static void SetStartup(bool enable)
        {
            //开机启动
            Microsoft.Win32.RegistryKey ms_run = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
            if (ms_run == null)
            {
                ms_run = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
            }
            if (enable)
            {
                ms_run.SetValue(Application.ProductName, Application.ExecutablePath.ToString());
            }
            else
            {
                ms_run.DeleteValue(Application.ProductName, false);
            }
        }
    }
}
